﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;

/* Copyright (c) 2014
 * author: Ricky Kratochwil
 * @ date: 2014-06-24
 * @ summary: Class for coins logic, houses animation objects
*/

namespace Engine
{
	class CCoin
	{
		private int				m_iValue;
		private CAnimationObj	m_oAnimObj;

		public CCoin(int iX, int iY, bool bCoin = true)
		{
			if(bCoin)
			{
				m_iValue = 1;			//Default value
				SetAnimation(iX, iY, Properties.Resources.coin_anim, 4);	//Create animation object and set animation-loop
			}
			else //Diamond
				m_iValue = 0;
			
		}

//////////////////////////////////////////////////////////////////////////////////////////////////////
////////// UTILITIES

		//Destroy animation object, effectively ending all animation
		// - Can only be called once
		//@ KR / 2014.07.07
		public void Destroy()
		{
			if(m_oAnimObj != null)
				CAnimationCore.RemoveAnimObj(m_oAnimObj.GetID());
		}

		//Create and set animation object
		//@ KR / 2014.07.08
		protected void SetAnimation(int iX, int iY, Bitmap oImage, int iSeq)
		{
			m_oAnimObj = new CAnimationObj(null, iX, iY);
			CAnimationCore.SetAnimObj(m_oAnimObj);
			m_oAnimObj.SetTickOffset(2);
			m_oAnimObj.SetAnimation(oImage, iSeq, Const.ANIM_STATION, true);
		}

		//Retrieve coin value
		//@ KR / 2014.05.21
		public int GetCoins()
		{		
			return m_iValue;
		}

		//Set coin value
		//@ KR / 2014.07.08
		protected void SetValue(int iValue)
		{
			m_iValue = iValue;
		}
	}
}
